﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsUserControl.UIUpdateWrapper
{
    /// <summary>
    /// udate image on picture box
    /// </summary>
    public class PictureBoxUpdator
    {
        private PictureBox _PicBox;
        private PictureBoxSizeMode _SizeMode;
        private Image _Img;

        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="picbox"></param>
        /// <param name="sizeMode"></param>
        /// <param name="img"></param>
        public PictureBoxUpdator(PictureBox picbox, PictureBoxSizeMode sizeMode, Image img)
        {
            this._PicBox = picbox;
            this._SizeMode = sizeMode;
            this._Img = img;

            this._PicBox.Invoke(new MethodInvoker(this.UpdatePicBoxImage));
        }

        private void UpdatePicBoxImage()
        {
            this._PicBox.SizeMode = this._SizeMode;
            this._PicBox.Image = this._Img;
            this._PicBox.Refresh();
        }
    }
}
